package com.blue.web.sys.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.blue.common.support.BaseController;
import com.blue.facade.sys.user.entity.Menu;
import com.blue.facade.sys.user.service.MenuFacade;

@Controller
@RequestMapping(value="/menu")
public class MenuController extends BaseController {
	
	@Autowired
	private MenuFacade facade;
	
	@RequestMapping(value="/main", method=RequestMethod.GET)
	public String main() {
		return viewName("main") ;
	}
	
	@RequestMapping(value="/category", method=RequestMethod.GET)
	@ResponseBody
	public List<Menu> getMenuCategory() {
		return this.facade.getMenuCategory() ;
	}
	
	@RequestMapping(value="/children/{id}", method=RequestMethod.GET)
	@ResponseBody
	public List<Menu> getMenuByParentId(@PathVariable Long id) {
		return this.facade.getMenuByParentId(id) ;
	}
	
	@RequestMapping(value="/list", method=RequestMethod.GET)
	@ResponseBody
	public List<Menu> getAllMenus() {
		return this.facade.getAllMenus() ;
	}

}
